package com.java8.MethodRef;

public class demo_3 {
    public static void main(String[] args) {
        Child c = new Child();
        c.sayHello();
    }
}
class Parent {
    public void hello() {
        System.out.println("父类 says hello");
    }
}

class Child extends Parent {
    public void cry(){
        System.out.println("子类: 嘤嘤嘤");
    }
    @Override
    public void hello() {
        System.out.println("子类 says hello");
    }

    public void sayHello() {
        Runnable cry = this::cry;   //引用子类方法
        Runnable r = super::hello; // 引用父类方法
        cry.run();  //输出: 子类: 嘤嘤嘤
        r.run(); // 输出：父类 says hello
    }
}